.TH std::basic_osyncstream::emit 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_osyncstream::emit \- std::basic_osyncstream::emit

.SH Synopsis
   void emit();

   Emits all buffered output and executes any pending flushes, by calling emit() on the
   underlying std::basic_syncbuf.

.SH Parameters

   \fI(none)\fP

.SH Example


// Run this code

 #include <iostream>
 #include <syncstream>

 int main()
 {
     {
         std::osyncstream bout(std::cout);
         bout << "Hello," << '\\n'; // no flush
         bout.emit(); // characters transferred; cout not flushed
         bout << "World!" << std::endl; // flush noted; cout not flushed
         bout.emit(); // characters transferred; cout flushed
         bout << "Greetings." << '\\n'; // no flush
     } // destructor calls emit(): characters transferred; cout not flushed

     // emit can be used for local exception-handling on the wrapped stream
     std::osyncstream bout(std::cout);
     bout << "Hello, " << "World!" << '\\n';
     try
     {
         bout.emit();
     }
     catch (...)
     {
         // handle exceptions
     }
 }

.SH Output:

 Hello,
 World!
 Greetings.
 Hello, World!

.SH See also

   destructor   destroys the basic_osyncstream and emits its internal buffer
                \fI(public member function)\fP
                atomically transmits the entire internal buffer to the wrapped
   emit         streambuf
                \fI(public member function of std::basic_syncbuf<CharT,Traits,Allocator>)\fP

